//@charset "utf-8"
var InputWrong = function (input, message, checkBox) {
	this.bindEvent = function () {
		var self = this;
		checkBox.unbind().bind('click',function () {
			if (checkBox.hasClass('c-on')) {
				checkBox.removeClass('c-on');
			} else {
				checkBox.addClass('c-on');
			}
			self.check();
		});
		input.on('focus',function () {
			self.check();
		});
		input.on('blur',function () {
			self.check();
		});
	},
	this.check = function () {
		var maxValue = parseFloat(input.attr("view_max_value"));
		var lessValue = parseFloat(input.attr("view_less_value"));
		var currValue = parseFloat(input.val());
		
		if ('' == input.val().replace(/\s/g, '')) {
			if (checkBox.hasClass('c-on')) {
				this.empty();
			} else {
				message.html('');	
			}
			return;
		}

		if (currValue > maxValue) {
			this.max();
			return;
		}

		if (currValue < lessValue) {
			this.less();
			return;
		}

		this.valid();
	},
	this.less = function () {
		message.css('color', '#b80c0c');
		message.html(message.attr("view_less_msg"));
	},
	this.max = function () {
		message.css('color', '#b80c0c');
		message.html(message.attr("view_max_msg"));
	},
	this.valid = function () {
		message.css('color', '#333');
		message.html(message.attr("view_valid_msg"));
	},
	this.empty = function () {
		message.css('color', '#b80c0c');
		if (checkBox.hasClass("c-on")) {
			message.html(message.attr("view_empty_msg"));
		}
	}
}